﻿<UserControl x:Class="Starehe.Views.NewExam"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:Starehe"
      xmlns:Controls="clr-namespace:Helper.Controls;assembly=Helper"
                  xmlns:ccl="clr-namespace:Starehe;assembly=Helper"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    d:DesignHeight="548" d:DesignWidth="984"
      mc:Ignorable="d" 
      
        Background="White" >
   
    <Grid Name="mnGrid">
        <TextBlock HorizontalAlignment="Left" Margin="20,20,0,0" Style="{DynamicResource Title}"  Text="New Exam" 
                   VerticalAlignment="Top"/>
        <TextBlock Text="Class" HorizontalAlignment="Left" Margin="87,80,0,0" VerticalAlignment="Top" />
        <ComboBox DisplayMemberPath="NameOfClass" HorizontalAlignment="Left" Margin="120,80,0,0" 
                  ItemsSource="{Binding AllClasses}"
                  SelectedValue="{Binding Path=SelectedClassID, Mode=TwoWay}" SelectedValuePath="ClassID" 
                  VerticalAlignment="Top" Width="194"/>
        <TextBlock Text="Name" HorizontalAlignment="Left" Margin="82,130,0,0" Name="label3" VerticalAlignment="Top" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="120,130,0,0" MaxLength="20" 
                 Text="{Binding Path=NewExam.NameOfExam, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="194" />

        <TextBlock  HorizontalAlignment="Left" Margin="198,166,0,0" Text="MAX (20 chararacters)" VerticalAlignment="Top" />
        <TextBlock  HorizontalAlignment="Left" Margin="350,80,0,0" Style="{DynamicResource Title0}" Text="Subjects to be Examined" VerticalAlignment="Top" />
        <DataGrid AutoGenerateColumns="False" Margin="350,109,30,50" Name="dataGrid1"
                  ItemsSource="{Binding Path=NewExam.Entries, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                  CanUserAddRows="False" CanUserResizeRows="False" CanUserReorderColumns="False" 
                  CanUserDeleteRows="True" RowHeaderWidth="0">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Name of Subject" Width="200*"
                        Binding="{Binding Path=NameOfSubject}" IsReadOnly="True"/>
                <DataGridTemplateColumn Header="Exam Date" Width="200*">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <DatePicker SelectedDate="{Binding ExamDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedDateFormat="Long" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="Time" Width="200*">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Controls:TimePicker SelectedTime="{Binding ExamTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
        <Button Content="_Save" HorizontalAlignment="Right" 
                Margin="0,0,10,10" Command="{Binding SaveCommand}" VerticalAlignment="Bottom" Width="75" />
        <TextBlock HorizontalAlignment="Right" Margin="0,88,35,0" VerticalAlignment="Top">
            <Hyperlink Command="{Binding RefreshCommand}">Refresh</Hyperlink>
        </TextBlock>
    </Grid>
</UserControl>
